<template>
  <div id="newList">
    <!-- 搜索区域 -->
    <div id="newSearch">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="">
          <el-input
            v-model="formInline.user"
            placeholder="请输入搜索内容"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search">搜索</el-button>
          <el-button
            type="primary"
            @click="dialogVisible = true"
            icon="el-icon-plus"
            >添加</el-button
          >
        </el-form-item>
      </el-form>
    </div>

    <!-- 弹窗区域 -->
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="40%"
      :before-close="handleClose"
    >
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false"
          >确 定</el-button
        >
      </span>
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="新闻标题">
          <el-input v-model="form.title"></el-input>
        </el-form-item>
        <el-form-item label="新闻作者">
          <el-select v-model="form.author" placeholder="请选择活动区域">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="发布时间">
          <el-col :span="11">
            <el-date-picker
              type="date"
              placeholder="选择日期"
              v-model="form.date"
              style="width: 100%"
            ></el-date-picker>
          </el-col>
        </el-form-item>
        <el-form-item label="是否上线">
          <el-switch v-model="form.delivery"></el-switch>
        </el-form-item>
        <el-form-item label="新闻内容">
          <el-input type="textarea" v-model="form.desc"></el-input>
        </el-form-item>
      </el-form>
    </el-dialog>

    <!-- 表格显示区域 -->
    <el-table :data="tableData" border>
      <el-table-column prop="title" label="新闻标题"> </el-table-column>
      <el-table-column prop="author" label="作者"> </el-table-column>
      <el-table-column prop="time" label="发布时间"> </el-table-column>
      <el-table-column label="操作">
        <el-button type="primary" icon="el-icon-edit">编辑</el-button>
        <el-button type="danger" icon="el-icon-delete">删除</el-button>
      </el-table-column>
    </el-table>

    <!-- 分页 -->
    <div id="Page">
      <el-pagination small layout="prev, pager, next" :total="50">
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  name: "newsList",
  data() {
    return {
      formInline: {
        user: "",
        region: "",
      },

      dialogVisible: false,

      form: {
        title: "",
        author: "",
        date: "",
        delivery: false,
        desc: "",
      },

      tableData: [
        {
          title: "民航局回应东航坠机传言：谣言",
          author: "抽屉视频",
          time: "2022年4月11日",
        },
        {
          title: "《加快建设全国统一大市场的意见》发布 解读来了",
          author: "央视新闻",
          time: "2022-04-11 10:36",
        },
      ],
    };
  },
  methods: {
    onSubmit() {},
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          done();
        })
        .catch((_) => {});
    },
  },
};
</script>

<style lang='scss'>
#newList {
  margin-top: 20px;
  margin-left: 10px;
  #Page{
    margin-top: 20px;
    text-align: right;
  }
}
</style>